package com.a3dweijing.wetouch2.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.a3dweijing.wetouch2.Common.listview.CommonListviewAdapter;
import com.a3dweijing.wetouch2.Common.listview.ViewHolderListview;
import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.Util.GlideUtil;
import com.a3dweijing.wetouch2.bean.ShoppingDetails;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2018/3/23.
 */

public class ShoppingEvaluateFragment extends Fragment
{
    @BindView(R.id.listview)
    ListView listview;
    
    Unbinder unbinder;
    
    private View view;
    
    private MyAdapter myAdapter;
    
    private ArrayList<ShoppingDetails.CommentBean> list;
    
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState)
    {
        view = inflater.inflate(R.layout.shoppingevaluatefragment, container, false);
        Bundle arguments = getArguments();
        list = (ArrayList<ShoppingDetails.CommentBean>)arguments.getSerializable("list");
        unbinder = ButterKnife.bind(this, view);
        initListview();
        return view;
    }
    
    private void initListview()
    {
        myAdapter = new MyAdapter(getActivity(), list, R.layout.shoppingevaluatefragment_item);
        listview.setAdapter(myAdapter);
    }
    
    @Override
    public void onDestroyView()
    {
        super.onDestroyView();
        unbinder.unbind();
    }
    
    class MyAdapter extends CommonListviewAdapter<ShoppingDetails.CommentBean>
    {
        
        public MyAdapter(Context context, List<ShoppingDetails.CommentBean> list, int layoutId)
        {
            super(context, list, layoutId);
        }
        
        @Override
        public void convert(ViewHolderListview holder, ShoppingDetails.CommentBean commentBean,int i)
        {
            ImageView view = holder.getView(R.id.head);
            String s = GlideUtil.getInstance().checkUrl(commentBean.getUser_head());
            GlideUtil.getInstance().showByCircle(getActivity(),s,view);
            TextView name = holder.getView(R.id.name);
            TextView time = holder.getView(R.id.time);
            TextView desc = holder.getView(R.id.desc);
            TextView num = holder.getView(R.id.num);
            name.setText(commentBean.getUser_name());
            time.setText(commentBean.getGoods_comment_time()+"");
            desc.setText(commentBean.getGoods_comment_info());
            num.setText("评分："+commentBean.getGoods_comment_style()+"分");

        }
    }
    
}
